package lu.med.praxiswahl.wahlumed.client.arztbriefe;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;

import lu.med.praxiswahl.wahlumed.client.wclient.Main;


/**
 * 
 * @author Lars Holger Roth
 */
public class ArztbriefMouseListener extends MouseAdapter
{
    private VorlagenEditor ord;
    private JTextArea view;

    public ArztbriefMouseListener(Main dataManager, JTextArea view,
	    VorlagenEditor ord)
    {
	this.view = view;
	this.ord = ord;
    }

    @Override
    public void mouseClicked(MouseEvent e)
    {
	if (SwingUtilities.isRightMouseButton(e))
	{
	    JList list = (JList) e.getSource();
	    int index = list.locationToIndex(e.getPoint());
	    if (index > -1)
		list.setSelectedIndex(index);
	    String txt = ord.getCurText(index);
	    if (txt != null)
		view.append(txt);
	}
    }
}